math function sum

The sum function returns the sum of the elements of the vector passed as an argument. Recall that vector are passed by pointers so that y = sum(X2) is not legal. Instead, on must explicitly calculate

 # Given vector X, the following calculates the sum of X^2
 let X2 = X^2
 let y = sum(X2)
in order to evaluate the sum. The sum function can be used to calculate basic statistics (mean, standard deviation, correlation, ...) and to do basic integration together with a spline-interp algorithm if the points are distant and the function smooth enough.

interp, spline